package com.huawei.ebg.crm.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class DBUtil {

    public static Connection getConnection() throws  Exception{

        //
        Properties properties=new Properties();

        // 让p去读取db.properties 然后读到 name
        InputStream inputStream = new FileInputStream(new File("src/main/resources/db.properties"));
        properties.load(inputStream);

        String driver = properties.getProperty("mysql.driver");
        Class.forName(driver);

        String url = properties.getProperty("mysql.url");
        String user = properties.getProperty("mysql.name");
        String password = properties.getProperty("mysql.password");

        Connection conn= DriverManager.getConnection(url,user,password);
        return conn;
    }
}
